import 'package:safetymonitor/generated/json/base/json_convert_content.dart';
import 'package:safetymonitor/app/data/entities/home/knownledge/knowledge_base_type_tree_entity.dart';
import 'package:safetymonitor/app/data/common/choice_bean.dart';


KnowledgeBaseTypeTreeEntity $KnowledgeBaseTypeTreeEntityFromJson(Map<String, dynamic> json) {
  final KnowledgeBaseTypeTreeEntity knowledgeBaseTypeTreeEntity = KnowledgeBaseTypeTreeEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    knowledgeBaseTypeTreeEntity.id = id;
  }
  final int? createTime = jsonConvert.convert<int>(json['createTime']);
  if (createTime != null) {
    knowledgeBaseTypeTreeEntity.createTime = createTime;
  }
  final String? label = jsonConvert.convert<String>(json['label']);
  if (label != null) {
    knowledgeBaseTypeTreeEntity.label = label;
  }
  final int? pid = jsonConvert.convert<int>(json['pid']);
  if (pid != null) {
    knowledgeBaseTypeTreeEntity.pid = pid;
  }
  final List<KnowledgeBaseTypeTreeEntity>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<KnowledgeBaseTypeTreeEntity>(e) as KnowledgeBaseTypeTreeEntity).toList();
  if (children != null) {
    knowledgeBaseTypeTreeEntity.children = children;
  }
  return knowledgeBaseTypeTreeEntity;
}

Map<String, dynamic> $KnowledgeBaseTypeTreeEntityToJson(KnowledgeBaseTypeTreeEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['createTime'] = entity.createTime;
  data['label'] = entity.label;
  data['pid'] = entity.pid;
  data['children'] = entity.children?.map((v) => v.toJson()).toList();
  return data;
}

extension KnowledgeBaseTypeTreeEntityExtension on KnowledgeBaseTypeTreeEntity {
  KnowledgeBaseTypeTreeEntity copyWith({
    int? id,
    int? createTime,
    String? label,
    int? pid,
    List<KnowledgeBaseTypeTreeEntity>? children,
  }) {
    return KnowledgeBaseTypeTreeEntity()
      ..id = id ?? this.id
      ..createTime = createTime ?? this.createTime
      ..label = label ?? this.label
      ..pid = pid ?? this.pid
      ..children = children ?? this.children;
  }
}